import requests
import re

url = "https://tieba.baidu.com/t/f/?class=college"
response = requests.get(url)
html  = response.text
universitys = re.findall(r'<a class="each_topic_entrance_item" href="//tieba.baidu.com/t/f/(.*?)" data-fid=".*?"> (.*?)</a> ',html,re.S)
for university in universitys:
    print("="*100)
    print(f"{university[1]}所有帖子...................")
    uni_url = f"https://tieba.baidu.com/t/f/{university[0]}"
    res = requests.get(uni_url)
    posts = re.findall(r'<a class="thread_title" href="//tieba.baidu.com/p/.*?">(.*?)</a>',res.text,re.S)
    for post in posts:
        print(post)

